import initSqlJs from 'sql.js'
// import * as sqlExecutor from '@/utils/sqlExecutor'
export const initDB = async (initSql) => {
  // 创建数据库
  const SQL = await initSqlJs({
    locateFile: () => {
      // return `https://cdn.jsdelivr.net/npm/sql.js/dist/sql-wasm.wasm`
      return  './node_modules/sql.js/dist/sql-wasm.wasm'
    }
  })
  const db = new SQL.Database()
  if (initSql) {
    db.run(initSql)
  }
  return db
}

export const runSQL = (db, sql) => {
  return db.exec(sql)
}
